<section class="content">
	<div class="row">
		<div class="col-md-12">
			<div class="box box-danger">
				<div class="box-body">
					<form id="admin_memberlist_edit_dialog_form">
						<input type="hidden" name="id" value="{$info.userid}"/>
						<table class="table">
							<tr>
								<td width="120">用户名：</td>
								<td>
									<if condition="!empty($info)">
										{$info.username}
										<else/>
										<input type="text" name="info[username]" value=""  style="width:180px;height:22px" />
									</if>
								</td>
								<td></td>
							</tr>
							<tr>
								<td>密码：</td>
								<td><input id="admin_memberlist_edit_dialog_form_password" type="password" name="info[password]" style="width:180px;height:22px" /></td>
								<td><div id="admin_memberlist_edit_dialog_form_passwordTip"></div></td>
							</tr>
							<tr>
								<td>确认密码：</td>
								<td><input id="admin_memberlist_edit_dialog_form_pwdconfirm" type="password" name="info[pwdconfirm]" style="width:180px;height:22px" /></td>
								<td><div id="admin_memberlist_edit_dialog_form_pwdconfirmTip"></div></td>
							</tr>
							<tr>
								<td>E-mail：</td>
								<td><input id="admin_memberlist_edit_dialog_form_email" type="text" name="info[email]" value="{$info.email}" style="width:180px;height:22px" /></td>
								<td><div id="admin_memberlist_edit_dialog_form_emailTip"></div></td>
							</tr>
							<tr>
								<td>真实姓名：</td>
								<td><input id="admin_memberlist_edit_dialog_form_realname" type="text" name="info[realname]" value="{$info.realname}" style="width:180px;height:22px" /></td>
								<td><div id="admin_memberlist_edit_dialog_form_realnameTip"></div></td>
							</tr>
							<tr>
								<td>所属角色：</td>
								<td>
									<select id="admin_memberlist_edit_dialog_form_role" class="easyui-combobox" data-options="editable:false,panelHeight:'auto'" name="info[roleid]" style="height:25px">
										<foreach name="rolelist" key="roleid" item="rolename">
											<option value="{$roleid}" <eq name="info.roleid" value="$roleid">selected</eq>>{$rolename}</option>
										</foreach>
									</select>
								</td>
								<td><div id="admin_memberlist_edit_dialog_form_roleTip"></div></td>
							</tr>
							<tr>
								<td>站点：</td>
								<td><select class="select2 " name="info[site]" style="width: 60%">
									<foreach name="mgrs" item="mgr">
										<option value="{$mgr['id']}" <eq name="info['site']" value="$mgr['id']"> selected</eq> >{$mgr['name']}</option>
									</foreach>
								</select></td>
								<td></td>
							</tr>

						</table>
						<div class="box-footer" >
                            <span class="input-group-btn">
                                <button class="btn btn-danger pull-left" type="button" id="close-dialog">取消</button>
                                <button class="btn btn-primary pull-right" type="button" id='form_submit' >提交</button>
                            </span>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</section>
<script type="text/javascript">
$(function(){
	$('#form_submit').click(function () {
		$('#admin_memberlist_edit_dialog_form').submit();
	});
	$.formValidator.initConfig({formID:"admin_memberlist_edit_dialog_form",onError:function(msg){},onSuccess:adminMemberlistEditDialogFormSubmit,submitAfterAjaxPrompt:'有数据正在异步验证，请稍等...',inIframe:true});
	$("#admin_memberlist_edit_dialog_form_password").formValidator({empty:true,onShow:"不修改密码请留空",onFocus:"密码应该为6-20位之间"}).inputValidator({min:6,max:20,onError:"密码应该为6-20位之间"});
	$("#admin_memberlist_edit_dialog_form_pwdconfirm").formValidator({onShow:"不修改密码请留空",onFocus:"请输入确认密码"}).compareValidator({desID:"admin_memberlist_edit_dialog_form_password",operateor:"=",onError:"输入两次密码不一致"});
	$("#admin_memberlist_edit_dialog_form_email").formValidator({onShow:"请输入E-mail",onFocus:"请输入E-mail"}).regexValidator({regExp:"email",dataType:"enum",onError:"E-mail格式错误"}).ajaxValidator({
		type : "post",
		url : "{:U('Admin/public_checkEmail')}",
		data : {email: function(){return $("#admin_memberlist_edit_dialog_form_email").val()}, default: '{$info.email}'},
		datatype : "json",
		async:'false',
		success : function(data){
			var json = $.parseJSON(data);
            return json.status == 1 ? false : true;
		},
		onError : "该邮箱已经存在",
		onWait : "请稍候..."
	});
	$("#admin_memberlist_edit_dialog_form_realname").formValidator({onShow:"请输入真实姓名",onFocus:"真实姓名应该为2-20位之间"}).inputValidator({min:2,max:20,empty:{leftEmpty:false,rightEmpty:false,emptyError:"姓名两边不能有空格"},onError:"真实姓名应该为2-20位之间"});
	$("#admin_memberlist_edit_dialog_form_role").formValidator({onShow:"请选择角色",onFocus:"请选择角色"}).inputValidator({min:0,onError:"请选择角色"});
});

function adminMemberlistEditDialogFormSubmit(){
	$.post("{:U('Admin/memberEdit')}", $("#admin_memberlist_edit_dialog_form").serialize(), function(res){
		if(!res.status){
			$.messager.alert('提示信息', res.info, 'error');
		}else{
			$.messager.alert('提示信息', res.info, 'info');
			$('#admin_memberlist_edit_dialog').dialog('close');
			dialog.get('dialogPage').close().remove();
			reloadContent();
		}
	})
}
</script>
